<?php
namespace app\system\controller;
class Param extends Common
{
    public function index()
    {
        return $this->fetch();
    }
    public function system($id = 0)
    {
        $paramModel = new \app\common\model\Param();
        if (isAjaxPost()) {
            $datas = input('post.');
            $id = intval($id);
            if ($id <= 0) {
                return $this->jsonError('参数错误');
            }

            $data = [
                'content' => serialize($datas)
            ];
            if ($paramModel->updateParam($data, ['id'=>$id]) !== false) {
                return $this->jsonSuccess('操作成功');
            } else {
                return $this->jsonError('操作失败');
            }
        }

        $param = $paramModel->findParam(['id'=>1]);
        $param->content = unserialize($param->content);
        $this->assign('data', $param);
        return $this->fetch();
    }

}
